home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1732 < prev    next >
Mailbox/MIME Entity  |  1996-08-05  |  1.5 KB

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: Mailbox/MIME Entity (archive/mbox).

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert Mailbox/MIME Entity (archive/mbox) magic Supported
1% dexvert Text File (text/txt) fallback Supported
100% file C source, ASCII text default
100% checkBytes Printable ASCII default
100% perlTextCheck Likely Text (Perl) default
100% siegfried fmt/950 MIME Email (1.0) default
100% detectItEasy Format: plain text[LF] default (weak)



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 4e 65 77 73 67 72 6f 75 | 70 73 3a 20 63 6f 6d 70 |Newsgrou|ps: comp|
|00000010| 2e 6c 61 6e 67 2e 63 0a | 50 61 74 68 3a 20 45 55 |.lang.c.|Path: EU|
|00000020| 2e 6e 65 74 21 73 75 6e | 34 6e 6c 21 72 69 76 6d |.net!sun|4nl!rivm|
|00000030| 21 6e 65 77 73 0a 46 72 | 6f 6d 3a 20 22 41 2e 20 |!news.Fr|om: "A. |
|00000040| 76 61 6e 20 4b 65 73 73 | 65 6c 22 20 3c 69 6d 61 |van Kess|el" <ima|
|00000050| 61 76 6b 3e 0a 53 75 62 | 6a 65 63 74 3a 20 52 65 |avk>.Sub|ject: Re|
|00000060| 3a 20 50 6f 69 6e 74 65 | 72 2d 74 6f 2d 44 6f 75 |: Pointe|r-to-Dou|
|00000070| 62 6c 65 20 61 73 20 46 | 75 6e 63 74 69 6f 6e 20 |ble as F|unction |
|00000080| 41 72 67 0a 43 6f 6e 74 | 65 6e 74 2d 54 79 70 65 |Arg.Cont|ent-Type|
|00000090| 3a 20 74 65 78 74 2f 70 | 6c 61 69 6e 3b 20 63 68 |: text/p|lain; ch|
|000000a0| 61 72 73 65 74 3d 75 73 | 2d 61 73 63 69 69 0a 4d |arset=us|-ascii.M|
|000000b0| 65 73 73 61 67 65 2d 49 | 44 3a 20 3c 44 4c 41 41 |essage-I|D: <DLAA|
|000000c0| 70 77 2e 49 30 45 40 72 | 69 76 6d 2e 6e 6c 3e 0a |pw.I0E@r|ivm.nl>.|
|000000d0| 54 6f 3a 20 6d 69 74 63 | 68 40 6e 65 77 73 2e 6d |To: mitc|h@news.m|
|000000e0| 64 6c 69 2e 63 6f 6d 0a | 53 65 6e 64 65 72 3a 20 |dli.com.|Sender: |
|000000f0| 6e 65 77 73 40 72 69 76 | 6d 2e 6e 6c 0a 43 6f 6e |news@riv|m.nl.Con|
|00000100| 74 65 6e 74 2d 54 72 61 | 6e 73 66 65 72 2d 45 6e |tent-Tra|nsfer-En|
|00000110| 63 6f 64 69 6e 67 3a 20 | 37 62 69 74 0a 4f 72 67 |coding: |7bit.Org|
|00000120| 61 6e 69 7a 61 74 69 6f | 6e 3a 20 52 69 6a 6b 73 |anizatio|n: Rijks|
|00000130| 69 6e 73 74 69 74 75 75 | 74 20 76 6f 6f 72 20 56 |instituu|t voor V|
|00000140| 6f 6c 6b 73 67 65 7a 6f | 6e 64 68 65 69 64 20 65 |olksgezo|ndheid e|
|00000150| 6e 20 4d 69 6c 69 65 75 | 68 79 67 69 65 6e 65 2c |n Milieu|hygiene,|
|00000160| 20 42 69 6c 74 68 6f 76 | 65 6e 2c 20 4e 4c 0a 52 | Bilthov|en, NL.R|
|00000170| 65 66 65 72 65 6e 63 65 | 73 3a 20 3c 34 64 66 63 |eference|s: <4dfc|
|00000180| 63 6c 24 6a 35 68 40 63 | 6f 6c 6f 73 73 75 73 2e |cl$j5h@c|olossus.|
|00000190| 68 6f 6c 6f 6e 65 74 2e | 6e 65 74 3e 0a 4d 69 6d |holonet.|net>.Mim|
|000001a0| 65 2d 56 65 72 73 69 6f | 6e 3a 20 31 2e 30 0a 44 |e-Versio|n: 1.0.D|
|000001b0| 61 74 65 3a 20 54 75 65 | 2c 20 31 36 20 4a 61 6e |ate: Tue|, 16 Jan|
|000001c0| 20 31 39 39 36 20 31 37 | 3a 31 37 3a 35 35 20 47 | 1996 17|:17:55 G|
|000001d0| 4d 54 0a 58 2d 4d 61 69 | 6c 65 72 3a 20 4d 6f 7a |MT.X-Mai|ler: Moz|
|000001e0| 69 6c 6c 61 20 31 2e 31 | 4e 20 28 58 31 31 3b 20 |illa 1.1|N (X11; |
|000001f0| 49 3b 20 4f 53 46 31 20 | 56 33 2e 30 20 61 6c 70 |I; OSF1 |V3.0 alp|
|00000200| 68 61 29 0a 58 2d 55 72 | 6c 3a 20 6e 65 77 73 3a |ha).X-Ur|l: news:|
|00000210| 34 64 66 63 63 6c 24 6a | 35 68 40 63 6f 6c 6f 73 |4dfccl$j|5h@colos|
|00000220| 73 75 73 2e 68 6f 6c 6f | 6e 65 74 2e 6e 65 74 0a |sus.holo|net.net.|
|00000230| 0a 59 6f 75 20 66 6f 72 | 67 6f 74 20 61 6e 20 61 |.You for|got an a|
|00000240| 73 74 65 72 69 78 2e 0a | 49 66 20 79 6f 75 20 6d |sterix..|If you m|
|00000250| 61 6c 6c 6f 63 20 61 20 | 66 6f 6f 20 3a 3d 20 79 |alloc a |foo := y|
|00000260| 6f 75 20 67 65 74 20 62 | 61 63 6b 20 61 20 66 6f |ou get b|ack a fo|
|00000270| 6f 2a 3b 0a 49 66 20 79 | 6f 75 20 6d 61 6c 6c 6f |o*;.If y|ou mallo|
|00000280| 63 20 6e 20 66 6f 6f 27 | 73 20 3a 3d 20 79 6f 75 |c n foo'|s := you|
|00000290| 20 67 65 74 20 62 61 63 | 6b 20 61 20 66 6f 6f 2a | get bac|k a foo*|
|000002a0| 20 3b 20 2f 2a 20 70 6f | 69 6e 74 69 6e 67 20 74 | ; /* po|inting t|
|000002b0| 6f 20 74 68 65 20 31 73 | 74 20 65 6c 65 6d 20 2a |o the 1s|t elem *|
|000002c0| 2f 0a 0a 49 6e 20 61 6c | 6c 20 63 61 73 65 73 3a |/..In al|l cases:|
|000002d0| 20 77 68 61 74 20 79 6f | 75 20 67 65 74 20 66 72 | what yo|u get fr|
|000002e0| 6f 6d 20 6d 61 6c 6c 6f | 63 20 69 73 20 61 20 70 |om mallo|c is a p|
|000002f0| 6f 69 6e 74 65 72 20 74 | 6f 20 73 6f 6d 65 70 6c |ointer t|o somepl|
|00000300| 61 63 65 20 69 6e 20 6d | 65 6d 6f 72 79 2e 0a 0a |ace in m|emory...|
|00000310| 54 6f 20 62 65 20 75 73 | 65 66 75 6c 20 79 6f 75 |To be us|eful you|
|00000320| 27 6c 20 68 61 76 65 20 | 74 6f 20 75 73 65 20 26 |'l have |to use &|
|00000330| 26 20 6b 65 65 70 20 74 | 68 69 73 20 70 6f 69 6e |& keep t|his poin|
|00000340| 74 65 72 3a 20 79 6f 75 | 20 77 6f 6e 74 20 67 65 |ter: you| wont ge|
|00000350| 74 20 69 74 20 61 20 73 | 65 63 6f 6e 64 0a 74 69 |t it a s|econd.ti|
|00000360| 6d 65 2e 20 53 6f 20 79 | 6f 75 20 68 61 76 65 20 |me. So y|ou have |
|00000370| 74 6f 20 72 65 74 75 72 | 6e 20 74 68 65 20 70 6f |to retur|n the po|
|00000380| 69 6e 74 65 72 20 74 6f | 20 74 68 65 20 63 61 6c |inter to| the cal|
|00000390| 6c 69 6e 67 20 66 75 6e | 63 74 69 6f 6e 2c 20 65 |ling fun|ction, e|
|000003a0| 69 74 68 65 72 20 61 73 | 0a 61 20 72 65 74 75 72 |ither as|.a retur|
|000003b0| 6e 2d 76 61 6c 75 65 20 | 6f 72 20 62 79 20 61 73 |n-value |or by as|
|000003c0| 73 69 67 6e 69 6e 67 20 | 69 74 20 74 6f 20 73 6f |signing |it to so|
|000003d0| 6d 65 74 68 69 6e 67 2e | 20 43 27 73 20 61 72 67 |mething.| C's arg|
|000003e0| 75 6d 65 6e 74 20 70 61 | 73 73 69 6e 67 20 69 73 |ument pa|ssing is|
|000003f0| 20 0a 63 61 6c 6c 2d 62 | 79 2d 76 61 6c 75 65 2c | .call-b|y-value,|
|00000400| 20 73 6f 20 69 66 20 79 | 6f 75 20 77 61 6e 74 20 | so if y|ou want |
|00000410| 74 6f 20 72 65 74 75 72 | 6e 20 61 20 66 6f 6f 2a |to retur|n a foo*|
|00000420| 20 62 79 20 61 73 73 69 | 67 6e 69 6e 67 20 74 6f | by assi|gning to|
|00000430| 20 61 6e 20 61 72 67 75 | 6d 65 6e 74 0a 79 6f 75 | an argu|ment.you|
|00000440| 20 6e 65 65 64 20 61 20 | 66 6f 6f 2a 2a 20 61 73 | need a |foo** as|
|00000450| 20 61 6e 20 61 72 67 75 | 6d 65 6e 74 20 2e 0a 2a | an argu|ment ..*|
|00000460| 2f 0a 69 6e 74 20 2a 20 | 6d 79 5f 61 6c 6c 6f 63 |/.int * |my_alloc|
|00000470| 31 28 69 6e 74 20 63 6e | 74 29 0a 7b 20 72 65 74 |1(int cn|t).{ ret|
|00000480| 75 72 6e 20 6d 61 6c 6c | 6f 63 20 28 63 6e 74 20 |urn mall|oc (cnt |
|00000490| 2a 20 73 69 7a 65 6f 66 | 20 69 6e 74 29 3b 20 7d |* sizeof| int); }|
|000004a0| 0a 0a 76 6f 69 64 20 6d | 79 5f 61 6c 6c 6f 63 32 |..void m|y_alloc2|
|000004b0| 28 69 6e 74 20 2a 2a 70 | 70 69 2c 20 69 6e 74 20 |(int **p|pi, int |
|000004c0| 63 6e 74 29 3b 0a 7b 20 | 69 6e 74 20 2a 70 3b 0a |cnt);.{ |int *p;.|
|000004d0| 70 20 3d 20 6d 61 6c 6c | 6f 63 20 28 63 6e 74 20 |p = mall|oc (cnt |
|000004e0| 2a 20 73 69 7a 65 6f 66 | 20 69 6e 74 29 3b 20 2a |* sizeof| int); *|
|000004f0| 70 70 69 20 3d 20 70 3b | 20 7d 0a 6d 61 69 6e 28 |ppi = p;| }.main(|
|00000500| 29 0a 7b 0a 69 6e 74 20 | 2a 70 31 2c 20 2a 70 32 |).{.int |*p1, *p2|
|00000510| 3b 0a 70 31 20 3d 20 20 | 6d 79 5f 61 6c 6c 6f 63 |;.p1 = |my_alloc|
|00000520| 31 28 31 30 29 3b 0a 6d | 79 5f 61 6c 6c 6f 63 32 |1(10);.m|y_alloc2|
|00000530| 28 26 70 32 2c 20 31 30 | 29 3b 0a 7d 0a 2f 2a 0a |(&p2, 10|);.}./*.|
|00000540| 42 6f 74 68 20 6d 65 74 | 68 6f 64 73 20 73 68 6f |Both met|hods sho|
|00000550| 75 6c 64 20 70 72 6f 64 | 75 63 65 20 65 71 75 69 |uld prod|uce equi|
|00000560| 76 61 6c 65 6e 74 20 72 | 65 73 75 6c 74 73 3a 20 |valent r|esults: |
|00000570| 0a 70 31 20 65 6e 20 70 | 32 20 73 68 6f 75 6c 64 |.p1 en p|2 should|
|00000580| 20 62 6f 74 68 20 63 6f | 6e 74 61 69 6e 20 70 74 | both co|ntain pt|
|00000590| 72 73 20 74 6f 20 31 30 | 20 63 6f 6e 73 65 63 75 |rs to 10| consecu|
|000005a0| 74 69 76 65 20 69 6e 74 | 73 20 62 79 20 6e 6f 77 |tive int|s by now|
|000005b0| 2e 0a 53 75 63 63 65 73 | 73 2e 0a 42 54 57 20 49 |..Succes|s..BTW I|
|000005c0| 20 73 74 69 6c 6c 20 74 | 68 69 6e 6b 20 69 74 27 | still t|hink it'|
|000005d0| 73 20 69 6e 20 54 68 65 | 20 46 41 51 2e 0a 41 64 |s in The| FAQ..Ad|
|000005e0| 72 69 61 61 6e 20 76 61 | 6e 20 4b 65 73 73 65 6c |riaan va|n Kessel|
|000005f0| 2e 0a 0a | |... | |
+--------+-------------------------+-------------------------+--------+--------+